<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var name = 'The Window';
        // let b = 2;
        var object = {
            name: 'My Object',
            getNameFunc: function(){
                // return this.name;
                var that = this;
                return function() {
                    return that.name;
                }
            }
        }

        console.log(object.getNameFunc()());
    </script>
</body>
</html>